import * as PIXI from 'pixi.js';
import StageConf from '../../conf/StageConf';
import ScalerUtil from '../../util/ScalerUtil';

export default class PointView extends PIXI.Sprite{
   
    id:number = 0;
    view:PIXI.Graphics;
    style:PIXI.TextStyle;
    txt:PIXI.Text;
    color:number;
    
    constructor(color:number){
        super();

        this.color = color;

        this.view = new PIXI.Graphics();
        this.view.interactive = true;

        // this.points = [];
        this.addChild(this.view);

        this.style = new PIXI.TextStyle({
            fontFamily: "Arial",
            fontSize: 36,
            fill: "white",
            stroke: '#333333',
            strokeThickness: 4,
            dropShadow: true,
            dropShadowColor: "#000000",
            dropShadowBlur: 4,
            dropShadowAngle: Math.PI / 6,
            dropShadowDistance: 6
        });
        this.txt = new PIXI.Text("0", this.style);
        this.txt.interactive = false;
        this.txt.anchor.set(0.5, 0.5);
        this.addChild(this.txt);

        this.init();
    }

    init(){
        this.draw();
    }
    
    draw(){
        this.view.clear();
        var weight = ScalerUtil.pxSize;
        this.view.lineStyle(weight, 0, 0.04);
        this.view.beginFill(this.color, 1);
        this.view.drawCircle(0, 0, 10 * weight);
        
        this.txt.text = this.id + "";
        this.txt.style.fontSize = weight * 14;
    }
    
}